//题型数据集。
Ext.define("ES.store.ItemTypesStore",{
    extend:"Ext.data.Store",
    model:"ES.model.ItemTypesModel",
    pageSize:20,
    remoteSort:true,
    autoLoad:false,
    proxy:{
        type:"ajax",
        url:"ItemType!list.action",
        reader:{
            type:"json",
            root:"dataSource.entityList",
            totalProperty:"dataSource.totalCounts"
        },
        listeners:{
            exception:function(proxy,resp,operation,opt){
                Ext.MessageBox.show({
                    title:"远程异常",
                    msg:operation.getError(),
                    icon:Ext.MessageBox.ERROR,
                    buttons:Ext.Msg.OK
                });
            }
        }
    },
    listeners:{
        beforeload:function(store,op){
            Ext.getBody().mask("正在加载数据，请稍后...");
            Ext.apply(store.proxy.extraParams,{
                ascProperty:"TypeName",
                asc:false
            });
        },
        load:function(){
            Ext.getBody().unmask();
        },
        update:function(store,record){
            var index = store.currentPage;
            Ext.Ajax.request({
                url:"ItemTypeEdit!update.action",
                params:{
                    typeID:record.get("typeID"),
                    typeName:record.get("typeName"),
                    typeCode:record.get("typeCode"),
                    jsEditClass:record.get("jsEditClass"),
                    analysisClass:record.get("analysisClass"),
                    antianalyticClass:record.get("antianalyticClass"),
                    assemblyName:record.get("assemblyName"),
                    description:record.get("description")
                },
                method:"POST",
                success:function(){
                    store.removeAll();
                    store.loadPage(index);
                }
            });
        },
        remove:function(store, record){
            var index = store.currentPage;
            Ext.Ajax.request({
                url:"ItemTypeEdit!delete.action",
                params:{
                    typeID:record.get("typeID")
                },
                method:"POST",
                success:function(){
                    store.removeAll();
                    store.loadPage(index);
                }
            });
        }
    }
})